package gs.sr.tkfxz.shared;

import java.io.Serializable;

import com.google.gwt.i18n.client.NumberFormat;

public class TaokeItem implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 1550070580850829517L;

	/**
	 * 返利账户，及nick
	 */
	private String rebateAccount;

	/**
	 * 鎺ㄥ箍鐐瑰嚮url
	 */
	private String clickUrl;

	/**
	 * 娣樺疂瀹剑閲�
	 */
	private String commission;

	/**
	 * 绱鎴愪氦閲�娉細杩斿洖鐨勬暟鎹槸30澶╁唴绱鎺ㄥ箍閲�
	 */
	private String commissionNum;

	/**
	 * 娣樺疂瀹剑閲戞瘮鐜囷紝姣斿锛�234.00浠ｈ〃12.34%
	 */
	private String commissionRate;

	/**
	 * 绱鎬绘敮鍑轰剑閲戦噺
	 */
	private String commissionVolume;

	/**
	 * 娣樺疂瀹㈠晢鍝乮d(娉ㄦ剰锛歩id杩戞湡鍗冲皢搴熷純锛岃鐢╪um_iid鍙傛暟)
	 */
	private String iid;

	/**
	 * 鍟嗗搧鎵�湪鍦�
	 */
	private String itemLocation;

	/**
	 * 娣樺疂瀹㈠叧閿瘝鎼滅储URL
	 */
	private String keywordClickUrl;

	/**
	 * 鍗栧鏄电О
	 */
	private String nick;

	/**
	 * 娣樺疂瀹㈠晢鍝佹暟瀛梚d
	 */
	private Long numIid;

	/**
	 * 商品图片url
	 * http://img02.taobaocdn.com/bao/uploaded/i2/T1ZuexXiFHXXcckdZZ_032046
	 * .jpg_80x80.jpg
	 */
	private String picUrl;

	/**
	 * 鍟嗗搧浠锋牸
	 */
	private String price;

	/**
	 * 鍗栧淇＄敤绛夌骇
	 */
	private Long sellerCreditScore;

	/**
	 * 鍟嗗搧鎵�湪搴楅摵鐨勬帹骞跨偣鍑籾rl
	 */
	private String shopClickUrl;

	/**
	 * 娣樺疂瀹㈢被鐩帹骞縐RL
	 */
	private String taobaokeCatClickUrl;

	/**
	 * 鍟嗗搧title 瀹濊礉鍚嶇О
	 */
	private String title;

	/**
	 * 30澶╁唴浜ゆ槗閲�
	 */
	private Long volume;

	public String getClickUrl() {
		return this.clickUrl;
	}

	public void setClickUrl(String clickUrl) {
		this.clickUrl = clickUrl;
	}

	public String getCommission() {
		return this.commission;
	}

	public void setCommission(String commission) {
		this.commission = commission;
	}

	public String getCommissionNum() {
		return this.commissionNum;
	}

	public void setCommissionNum(String commissionNum) {
		this.commissionNum = commissionNum;
	}

	public String getCommissionRate() {
		return this.commissionRate;
	}

	public void setCommissionRate(String commissionRate) {
		this.commissionRate = commissionRate;
	}

	public String getCommissionVolume() {
		return this.commissionVolume;
	}

	public void setCommissionVolume(String commissionVolume) {
		this.commissionVolume = commissionVolume;
	}

	public String getIid() {
		return this.iid;
	}

	public void setIid(String iid) {
		this.iid = iid;
	}

	public String getItemLocation() {
		return this.itemLocation;
	}

	public void setItemLocation(String itemLocation) {
		this.itemLocation = itemLocation;
	}

	public String getKeywordClickUrl() {
		return this.keywordClickUrl;
	}

	public void setKeywordClickUrl(String keywordClickUrl) {
		this.keywordClickUrl = keywordClickUrl;
	}

	public String getNick() {
		return this.nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public Long getNumIid() {
		return this.numIid;
	}

	public void setNumIid(Long numIid) {
		this.numIid = numIid;
	}

	public String getPicUrl() {
		return this.picUrl;
	}

	public void setPicUrl(String picUrl) {
		this.picUrl = picUrl;
	}

	public String getPrice() {
		return this.price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public Long getSellerCreditScore() {
		return this.sellerCreditScore;
	}

	public void setSellerCreditScore(Long sellerCreditScore) {
		this.sellerCreditScore = sellerCreditScore;
	}

	public String getShopClickUrl() {
		return this.shopClickUrl;
	}

	public void setShopClickUrl(String shopClickUrl) {
		this.shopClickUrl = shopClickUrl;
	}

	public String getTaobaokeCatClickUrl() {
		return this.taobaokeCatClickUrl;
	}

	public void setTaobaokeCatClickUrl(String taobaokeCatClickUrl) {
		this.taobaokeCatClickUrl = taobaokeCatClickUrl;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Long getVolume() {
		return this.volume;
	}

	public void setVolume(Long volume) {
		this.volume = volume;
	}

	/**
	 * 转成百分比
	 * 
	 * @author <a href="mailto:zhenbei@taobao.com">震北</a>
	 * @since 2012-2-3 下午2:50:58
	 * 
	 * @return
	 */
	private static String getCommissionRateInPercent(String commissionRate) {
		if (commissionRate != null) {
			try {
				double od = Double.parseDouble(commissionRate);
				od = od / 100;
				return NumberFormat.getFormat("#.00").format(od) + "%";
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return commissionRate;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(
				"<div id=\"result\"><div id=\"item\"><img id=\"pic_url\" src=\"")
				.append(this.picUrl)
				.append("\" height=\"50\" /><p><a href=\"http://item.taobao.com/item.htm?id=")
				.append(this.numIid).append("\" target=\"_blank\">")
				.append(this.title).append("</a></p><br />原价：￥")
				.append(this.price)
				.append("</div><div id=\"discount\">发现商品隐藏折扣<br /><span>")
				.append(getCommissionRateInPercent(this.commissionRate))
				.append("</span></div><div id=\"share\"></div></div>");

		return sb.toString();
	}

	public String getRebateAccount() {
		return rebateAccount;
	}

	public void setRebateAccount(String rebateAccount) {
		this.rebateAccount = rebateAccount;
	}

}
